// Newton Polynomial

#include <cstdio>
#include <iostream>
#include <array>
#include <vector>

using namespace std;

constexpr int SIZE = 11;

static void matrix_show(array<array<int64_t, SIZE>, SIZE>& m) {
    for (auto& v : m) {
        for (auto& e : v) 
            printf("%-10ld ", e);
        printf("\n");
    }    
}

template <typename Iterator>
static vector<int64_t> get_divided_differences(Iterator begin, Iterator end) {
    vector<int64_t> a;
    while (begin != end) {
        a.push_back(*begin);
        ++begin;
    }

    vector<int64_t> v;
    for (int i = 0; ; ++i) {
        v.push_back(a[0]);
        if (a.size() == 1)
            break;

        vector<int64_t> b;
        for (int j = 1; j < a.size(); ++j) {
            b.push_back((a[j] - a[j - 1]) / (i + 1));     
        }
        a = b;
    }
    return v;
}

static int64_t polynomial_generating_function(int n) {
    vector<int64_t> v {1};
    for (int i = 0; i < SIZE - 1; ++i)
        v.push_back(n * v[i]);

    int64_t ans = 0;
    for (int i = 0; i < v.size(); ++i) {
        if (i % 2)
            ans -= v[i];
        else 
            ans += v[i];
    }
    return ans;
}

int main() {
    array<array<int64_t, SIZE>, SIZE> arr {{0}};
    for (int j = 0; j < SIZE; ++j) {
        int64_t t = polynomial_generating_function(j + 1);
        for (int i = j; i < SIZE; ++i) {
            arr[i][j] = t;
        }
    }
    matrix_show(arr);

    vector<int64_t> df = get_divided_differences(arr.back().begin(), arr.back().end());
    for (auto e : df)
        printf("%ld ", e);
    printf("\n");

    for (int i = 0; i < arr[0].size(); ++i)
        arr[0][i] = 1;
    for (int i = 1; i < arr.size(); ++i) {
        for (int j = i + 1; j < arr[i].size(); ++j) {
            int64_t p = df[i];
            for (int k = 1; k <= i; ++k)
                p *= (j + 1 - k);
            arr[i][j] = arr[i - 1][j] + p;
        }
    }
    matrix_show(arr);

    int64_t ans = 0;
    for (int i = 0, j = 1; i < arr.size() && j < arr[0].size(); ++i, ++j) {
        ans += arr[i][j];
    }
    printf("%ld \n", ans);
}